package com.wu.spark

import org.apache.spark.sql.SparkSession


/**
  * DataSet的操作  // 老是找不到列transactionId 该类有错误
  */
object DataSetAPP {

  def main(args: Array[String]) {


    val spark = SparkSession.builder().appName("DataSetAPP").master("local[2]").getOrCreate();
    // 添加隐式转化
    import spark.implicits._
    val path = "C://Users//wudl//Documents//ideaWorkSpaces2018.4.13//SparkSQL//Sources//data.csv";
    val dfs = spark.read.option("head","true").option("inferSchema","true").csv(path);
    dfs.show

    val ds = dfs.as[Sales]
    ds.map(line => line.itemId).show
  }


  case  class Sales(transactionId:Int,customerId:Int,itemId:Int,amountPaid:Double)
}
